package com.ht.right.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ht.right.dao.RoleDao;
import com.ht.right.entity.Role;
import com.ht.right.service.RoleService;

public class RoleServiceImpl implements RoleService {
	private RoleDao roleDao;

	public RoleDao getRoleDao() {
		return roleDao;
	}

	public void setRoleDao(RoleDao roleDao) {
		this.roleDao = roleDao;
	}

	@Override
	public void saveRole(Role role) {
		// TODO Auto-generated method stub
		roleDao.save(role);
	}

	@Override
	public void updateRole(Role role) {
		// TODO Auto-generated method stub
		roleDao.update(role);
	}

	@Override
	public Role findRoleById(Role role) {
		// TODO Auto-generated method stub
		return roleDao.findRoleById(role);
	}

	@Override
	public void deleteRole(Role role) {
		// TODO Auto-generated method stub
		roleDao.delete(role);
	}

	@Override
	public void deleteRoles(String roles) {
		// TODO Auto-generated method stub
		roleDao.deleteRoles(roles);
	}

	@Override
	public List<Map<String, String>> findAllRoleJson() {
		// TODO Auto-generated method stub
		Map<String, String> map = null;
		List<Map<String, String>> list = new ArrayList<Map<String, String>>();
		List<Role> listRole = roleDao.findAllList();
		for (Role r : listRole) {
			map = new HashMap<String, String>();
			map.put("id", r.getUuid());
			map.put("text", r.getRoleName());
			map.put("type", "role");
			list.add(map);
		}
		return list;
	}
}
